package com.bootdo.clouddo.service.douban.impl;

import com.bootdo.clouddo.dao.douban.DbSubjectCollectionItemMapper;
import com.bootdo.clouddo.domain.douban.DbSubjectCollectionItem;
import com.bootdo.clouddo.service.douban.IDbSubjectCollectionItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DbSubjectCollectionItemServiceImpl implements IDbSubjectCollectionItemService {

    @Autowired
    private DbSubjectCollectionItemMapper dao;

    @Override
    public DbSubjectCollectionItem findById(Long id) {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public int save(DbSubjectCollectionItem record) {
        return dao.insertSelective(record);
    }

    @Override
    public int saveBatch(List<DbSubjectCollectionItem> records) {
        dao.deleteByCollectionId(records.get(0).getCollectionId());
        return dao.insertList(records);
    }

    @Override
    public List<DbSubjectCollectionItem> findItemsByCollection(String collectionId) {
        return dao.findItemsByCollection(collectionId);
    }

    @Override
    public List<Long> findAllIds() {
        return dao.findAllIds();
    }
}
